import 'dart:async';

import 'package:flutter/services.dart';

class NativeManager {
  static EventChannel createEventChannel(String name) {
    return EventChannel(name);
  }

  static StreamSubscription register(
      EventChannel channel, Function(Object) onData) {
    return channel.receiveBroadcastStream().listen(onData);
  }

  static MethodChannel createMethodChannel(String name) {
    return MethodChannel(name);
  }

  static Future<Null> sendDataToNative(
      MethodChannel sendToNative, String method,
      {Map<String, Object> map}) async {
    String result = await sendToNative.invokeMethod(method, map);
    print(result);
  }
}
